<?php

namespace App\Models\Oauth;

use Illuminate\Support\Facades\DB;
use App\Models\Model;

class MemberModel extends Model{

    const TABLENAME = 'tw_base_member';

    /**
     * 初始化并返回数据库请求构建器
     *
     * @return Illuminate\Support\Facades\DB::table(TABLENAME)
     */
    public static function dbTable()
    {
        // return self::dbConnectionClub()->table(self::TABLE_NAME);
        return DB::table(self::TABLENAME);
    }

    /**
     * 添加一个用户member信息
     */
    public static function addMember($data = array())
    {
        if (self::dbTable()->insertGetId($data)) {
            return true;
        }
        return false;
    }

    /**
     * 更新用户信息
     *  $where[] = ['id', '=', $id];
     */
    public static function updateMember($where = array(), $data = array())
    {
        return self::dbTable()->where($where)->update($data);
    }

    /**
     * 查询用户member表信息
     */
    public static function getMember($where = array())
    {
        return self::dbTable()->where($where)->first();
    }
}

?>